package com.isoft.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.isoft.dao.SysLogDao;
import com.isoft.entity.SysLogContent;
import com.isoft.service.ISysLogService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Slf4j
@Service
public class SysLogService implements ISysLogService {
    @Autowired
    SysLogDao sysLogDao;

    @Override
    public IPage<SysLogContent> getSysLog(int currentPage, int size) {
        Page<SysLogContent> pageRequest = new Page<>(currentPage, size);
        IPage<SysLogContent> sysLogContentIPage = sysLogDao.getAll(pageRequest);

        log.error("总记录数" + sysLogContentIPage.getTotal());
        log.error("总页数" + sysLogContentIPage.getPages());
        log.error("当前页" + (sysLogContentIPage.getCurrent()));
        log.error("当前页记录个数" + sysLogContentIPage.getRecords().size());
        log.error("当前页记录" + sysLogContentIPage.getRecords());

        return sysLogContentIPage;
    }

    @Override
    public Boolean delLog(Integer id) {
        return sysLogDao.delLog(id) > 0;
    }

    @Override
    public IPage<SysLogContent> getByCons(int currentPage, int size, String systype, String oprtype) {
        Page<SysLogContent> pageRequest = new Page<>(currentPage, size);
        IPage<SysLogContent> sysLogContentIPage = sysLogDao.getByCons(pageRequest,systype,oprtype);

        log.error("总记录数" + sysLogContentIPage.getTotal());
        log.error("总页数" + sysLogContentIPage.getPages());
        log.error("当前页" + (sysLogContentIPage.getCurrent()));
        log.error("当前页记录个数" + sysLogContentIPage.getRecords().size());
        log.error("当前页记录" + sysLogContentIPage.getRecords());

        return sysLogContentIPage;
    }
}
